#pragma once
#ifndef __G_QUAD_H__
#define __G_QUAD_H__

#include "GPlane.h"
#include "GVector3.h"
#include "GTriangle3.h"
#include "GUtilities/GTypes.h"

namespace GMath
{

	class GQuad
	{
	public:
		// CW orientation
		GVector3		Point0;
		GVector3		Point1;
		GVector3		Point2;
		GVector3		Point3;

						GQuad();
						GQuad(const GVector3& P0, const GVector3& P1, const GVector3& P2, const GVector3& P3);

		void			Create(const GVector3& P0, const GVector3& P1, const GVector3& P2, const GVector3& P3);

		float			GetArea() const;
		GVector3		GetCenter() const;
		GVector3		GetNormal() const;
		
		bool			CheckFront(const GVector3& ViewVec, bool TwoSided = false) const;
		bool			CheckPlanar() const;
		bool			CheckConvex() const;

		static void		Convert(OUTPUT GPlane& Output, const GQuad& Quad);
		static void		Convert(OUTPUT GTriangle3& Output1, OUTPUT GTriangle3& Output2, const GQuad& Quad);
	
		const GQuad& operator = (const GQuad& Other);
	};

}

#endif